package com.fbty.mt.action.user;

import java.io.ByteArrayInputStream;

import com.fbty.base.action.BaseAction;
import com.fbty.mt.utils.ImgCode;

@SuppressWarnings("serial")
public class CheckCodeAction extends BaseAction {
	
	private ByteArrayInputStream inputStream;
    
	private String code;
	
	private boolean flag;
	public String draw(){
		String code = ImgCode.getCode();
		try {
			inputStream = ImgCode.drawImg(code);
		} catch (Exception e) {
			e.printStackTrace();
		}
		sessionMap.put("code", code);
		
		return "img";
	}
	
	public String code(){
		String scode = (String)sessionMap.get("code");
		if(code.toUpperCase().equals(scode)){
			flag = true;
		}
		return "ok";
	}
	public String adminCode(){
		String scode = (String)sessionMap.get("adminCode");
		if(code.toUpperCase().equals(scode)){
			flag = true;
		}
		return "ok";
	}
	public ByteArrayInputStream getInputStream() {
		return inputStream;
	}

	public boolean isFlag() {
		return flag;
	}

	public void setCode(String code) {
		this.code = code;
	}
	
	
}
